/**
 * 
 */
package id.web.faisalabdillah.xtimesheet.services.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.google.appengine.api.datastore.Key;

import id.web.faisalabdillah.xtimesheet.dao.IRoleDao;
import id.web.faisalabdillah.xtimesheet.domain.Role;
import id.web.faisalabdillah.xtimesheet.services.IRoleService;

/**
 * @author faitz
 *
 */

@Service
@Transactional(readOnly=true)
public class RoleServiceImpl implements IRoleService {

	@Autowired
	private IRoleDao roleDao;
	/* (non-Javadoc)
	 * @see id.web.faisalabdillah.xtimesheet.services.IRoleService#insert(id.web.faisalabdillah.xtimesheet.domain.Role)
	 */
	@Override
	@Transactional(readOnly=false)
	public boolean insert(Role role) {
		try {
			roleDao.insert(role);
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}

	/* (non-Javadoc)
	 * @see id.web.faisalabdillah.xtimesheet.services.IRoleService#update(id.web.faisalabdillah.xtimesheet.domain.Role)
	 */
	@Override
	@Transactional(readOnly=false)
	public boolean update(Role role) {
		try {
			roleDao.update(role);
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}

	/* (non-Javadoc)
	 * @see id.web.faisalabdillah.xtimesheet.services.IRoleService#remove(id.web.faisalabdillah.xtimesheet.domain.Role)
	 */
	@Override
	@Transactional(readOnly=false)
	public boolean remove(Role role) {
		try {
			roleDao.remove(role);
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}

	/* (non-Javadoc)
	 * @see id.web.faisalabdillah.xtimesheet.services.IRoleService#findById(com.google.appengine.api.datastore.Key)
	 */
	@Override
	public Role findById(Key key) {
		return roleDao.findById(key);
	}

	/* (non-Javadoc)
	 * @see id.web.faisalabdillah.xtimesheet.services.IRoleService#getByCode(java.lang.String)
	 */
	@Override
	public Role getByCode(String code) {
		// TODO Auto-generated method stub
		return roleDao.getByCode(code);
	}

	/* (non-Javadoc)
	 * @see id.web.faisalabdillah.xtimesheet.services.IRoleService#sizeAll()
	 */
	@Override
	public int sizeAll() {
		// TODO Auto-generated method stub
		return roleDao.sizeAll();
	}

	/* (non-Javadoc)
	 * @see id.web.faisalabdillah.xtimesheet.services.IRoleService#listAll()
	 */
	@Override
	public List<Role> listAll() {
		// TODO Auto-generated method stub
		return roleDao.listAll();
	}

	/* (non-Javadoc)
	 * @see id.web.faisalabdillah.xtimesheet.services.IRoleService#listAllPaged(int, int)
	 */
	@Override
	public List<Role> listAllPaged(int first, int max) {
		// TODO Auto-generated method stub
		return roleDao.listAllPaged(first, max);
	}

	/* (non-Javadoc)
	 * @see id.web.faisalabdillah.xtimesheet.services.IRoleService#searchByCode(java.lang.String)
	 */
	@Override
	public List<Role> searchByCode(String code) {
		// TODO Auto-generated method stub
		return roleDao.searchByCode(code);
	}

	/* (non-Javadoc)
	 * @see id.web.faisalabdillah.xtimesheet.services.IRoleService#searchByCodeSize(java.lang.String)
	 */
	@Override
	public int searchByCodeSize(String code) {
		// TODO Auto-generated method stub
		return roleDao.searchByCodeSize(code);
	}

	/* (non-Javadoc)
	 * @see id.web.faisalabdillah.xtimesheet.services.IRoleService#searchByNamePaged(java.lang.String, int, int)
	 */
	@Override
	public List<Role> searchByNamePaged(String name, int first, int max) {
		// TODO Auto-generated method stub
		return roleDao.searchByNamePaged(name, first, max);
	}

}
